PATHMac OS 8 and 9 Developer Documentation > Human Interface Toolbox > Control Manager >

Programming With the Mac OS 8.5 Control Manager


MyControlEditTextValidationProc

Ensures that the content of an editable text control is valid.

This is how you would declare an editable text validation function, if you were to name the function MyControlEditTextValidationProc :

pascal void MyControlEditTextValidationProc (
                     ControlHandle control);
control
A value of type ControlHandle . You are passed a handle to the control containing the editable text to be validated.

DISCUSSION

Your application typically uses a MyControlEditTextValidationProc function in conjunction with a key filter function to ensure that editable text is valid in cases such as a cut, paste, or clear, where a key filter cannot be called. Use the kControlEditTextValidationProcTag control data tag constant, described in Control Data Tag Constants , with the functions SetControlData and GetControlData to set or retrieve a MyControlEditTextValidationProc function.

Note that if you are using the inline input editable text control variant, the Control Manager will not call your MyControlEditTextValidationProc function during inline input. Instead, you may install your own Text Services Manager TSMTEPostUpdateUPP callback function to validate text during inline input, or your application can validate the input itself, immediately prior to using the text.

Listing 1-2 in Validating Editable Text demonstrates how you can use a MyControlEditTextValidationProc function to ensure that a user-supplied file name does not contain any illegal characters.

When you implement your editable text validation function, the pointer that you pass to SetControlData must be a universal procedure pointer of the following type:

typedef ControlEditTextValidationProcPtr ControlEditTextValidationUPP;

To create a universal procedure pointer for your application-defined editable text validation function, you should use the NewControlEditTextValidationProc macro as follows:

ControlEditTextValidationUPP myControlEditTextValidationUPP;
myControlEditTextValidationUPP = NewControlEditTextValidationProc
(MyControlEditTextValidationProc);

You can then pass myControlEditTextValidationUPP in the inData parameter of SetControlData . When you no longer need the universal procedure pointer, you should remove it using the DisposeRoutineDescriptor function.

If you need to call your application-defined function from outside your application for some reason (for example, from a plug-in), you should use the CallControlEditTextValidationProc macro to make the call, as follows:

ControlEditTextValidationUPP myControlEditTextValidationUPP;
CallControlEditTextValidationProc (myControlEditTextValidationUPP, control);

Using this macro ensures that the call is made through a universal procedure pointer.


VERSION NOTES

Available with Mac OS 8.5 and later.


© 1999 Apple Computer, Inc. — (Last Updated 20 Jan 99)